package piwan;

import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;

public class RegionType {
	static public final int soldiersPerCombo = 1;
	
	public RegionType() {
		name = "<unnamed>";
		id = -1;
		combo = -1;
		maxAttack = 6;
		def = 0;
		capital = false;
	}
	
	public RegionType set(String newName,int newId, int newCombo, int newMaxAttack, boolean newCapital, int newDefenseBonus) {
		name = newName;
		id = newId;
		combo = newCombo;
		maxAttack = newMaxAttack;
		capital = newCapital;
		def = newDefenseBonus;
		return this;
	}
	
	public void setId(int newId) {
		id = newId;
	}
	
	public RegionType clone() {
		return (new RegionType()).set(name, id, combo, maxAttack, capital,def); 
	}
	
	public String		getName() {
		return name;
	}
	
	
	public int			getCombo() {
		return combo;
	}
	
	public boolean		hasCombo() {
		return combo!=0;
	}
	
	public int			getMaxAttack() {
		return maxAttack;
	}
	
	public boolean		isCapital() {
		return capital;
	}
	
	public int			getId() {
		return id;
	}
	
	public int getDefenseBonus() {
		return def;
	}
	
	public int getSoldiersFor(int n) {  return n/combo * soldiersPerCombo; }
	
	public void writeText( Writer writer ) throws IOException {
		writer.write(name + " " + combo + " " + capital + " " + maxAttack + " " + def + "\n");
	}
	
	public void readText( Scanner scan ) throws IOException {
		name = scan.next();
		combo = scan.nextInt();
		capital	= scan.nextBoolean();
		maxAttack = scan.nextInt();
		def = scan.nextInt();
	}
	
	private String name;
	private boolean capital;
	private int id,combo,maxAttack;
	private int def;
}
